package cn.com.css.taxInspection.attention.controller;

import cn.com.css.taxInspection.attention.entity.JcAyqksmEntity;
import cn.com.css.taxInspection.attention.entity.JcAyqksmmxEntity;
import cn.com.css.taxInspection.attention.service.JcAyqksmService;
import cn.com.css.taxInspection.attention.service.JcAyqksmmxService;
import cn.com.css.taxInspection.common.aop.annotation.LogAnnotation;
import cn.com.css.taxInspection.common.result.DataResult;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

@RequestMapping("/ayhj")
@RestController
@Api(tags = "案源环节-案源情况说明")
public class AyhjController {

    @Resource
    private JcAyqksmService jcAyqksmService;

    @Resource
    private JcAyqksmmxService jcAyqksmmxService;

    @ApiOperation(value = "案源环节-查询案源情况说明列表")
    @LogAnnotation(title = "案源环节", action = "查询案源情况说明列表")
    @PostMapping("/ayqksm/queryJcayqksmTable")
    @ResponseBody
    @DS("oracle")
    public DataResult queryJcayqksmTable(@RequestBody JcAyqksmEntity jcAyqksmEntity) throws ParseException {
        IPage<JcAyqksmEntity> iPage = jcAyqksmService.queryJcAyqksmTable(jcAyqksmEntity);
        return DataResult.success(iPage);
    }


    @ApiOperation(value = "案源环节-保存案源情况说明线索")
    @LogAnnotation(title = "案源环节", action = "保存案源情况说明线索")
    @PostMapping("/ayqksm/saveAyqksmXs")
    @ResponseBody
    @DS("oracle")
    public DataResult saveAyqksmXs(@RequestBody List<JcAyqksmmxEntity> jcAyqksmmxEntityList) throws ParseException {
        int result = jcAyqksmmxService.saveJcAyqksmmx(jcAyqksmmxEntityList);
        return DataResult.success(result);
    }

    @ApiOperation(value = "案源环节-查询案源情况说明线索")
    @LogAnnotation(title = "案源环节", action = "保存案源情况说明线索")
    @PostMapping("/ayqksm/queryAyqksmXs")
    @ResponseBody
    @DS("oracle")
    public DataResult queryAyqksmXs(@RequestBody Map<String, String> params) {
        String jcajxxuuid = params.get("jcajxxuuid");
        List<JcAyqksmmxEntity> jcAyqksmmxEntityList = jcAyqksmmxService.queryAyqksmXsByJcajxxuuid(jcajxxuuid);
        return DataResult.success(jcAyqksmmxEntityList);
    }
}
